LastSelectable
interface LastSelectable
A parent element marked as LastSelectable will cache the last selected element when a popup or other overlay is rendered, and return to that selection when the popup/overlay is removed.
Author
fzzyhmstrs
Since
0.2.0, added resetHover 0.6.0
Samples
import me.fzzyhmstrs.fzzy_config.screen.LastSelectable
import me.fzzyhmstrs.fzzy_config.screen.widget.LayoutWidget
import me.fzzyhmstrs.fzzy_config.screen.widget.PopupWidget
import me.fzzyhmstrs.fzzy_config.screen.widget.custom.CustomButtonWidget
import net.minecraft.client.MinecraftClient
import net.minecraft.client.gui.Element
import net.minecraft.client.gui.ParentElement
import net.minecraft.client.gui.widget.TextWidget
import net.minecraft.text.Text
import net.minecraft.util.Identifier
fun main() {
//sampleStart
//simple stub example of a LastSelectable, passing its focused element back and forth with its lastSelected cache
abstract class ExampleLastSelectable: ParentElement, LastSelectable {
override var lastSelected: Element? = null
override fun pushLast() {
lastSelected = focused
}
override fun popLast() {
focused = lastSelected
}
}
//sampleEnd
}
Inheritors
Functions
Link copied to clipboard
Indicates that the overlay has been removed and the parent should return focus to the cached element, if any, in lastSelected
Link copied to clipboard
Indicates to the parent element to cache it's current focused element. The current focused element should be stored in lastSelected
Link copied to clipboard
When called the parent element should reselect a hovered element based on the supplied mouse positions, if it tracks such things